
import { timeFn } from '@/utils/index'
export default {
  data() {
    return {
      tagType: {
        selfService: {
          '1': 'warning', // 编辑
          '2': 'info', // 待派发
          '50': 'success', // 已完成
          '90': 'success', // 升级处理完成
          '11': 'danger', // "升级处理中"
          '20': 'danger', // "处理中"
          '5': '', // 未确认
          '10': '', // 未接收
          '70': 'info' // 升级中
        }
      },
      ruleForm: {
        workOrderNo: null,
        systemName: null,
        eventStatus: null,
        eventLevel: null,
        eventSource: null,
        faultType: null,
        area: null,
        declarer: null,
        receiver: null,
        faultPhenomenon: null
      },
      dialogVisible: false
    }
  },
  computed: {
    searchOptions() {
      return [
        {
          value: 'cableCode',
          key: 'cableCode',
          label: '电文代码',
          type: 'input',
          placeholder: '请输入电文代码'
        },
        {
          value: 'receiveTime',
          key: 'receiveTime',
          dateType: 'datetimerange',
          label: '接收时间',
          type: 'date',
          style: 'width: 220px',
          valueFormat: 'yyyy-MM-dd HH:mm:ss',
          placeholder: '请选择接收时间'
        }
      ]
    },
    tablecolumn() {
       return [
          {
            width: '55',
            fixed: 'left',
            type: 'selection',
            reserveSelection: true,
            align: 'center'
          },
          {
            width: '120',
            label: '序号',
            align: 'center',
            prop: 'seqNo',
            render: (h, params) => {
              return h('a', {
               style: {
                 color: '#1890ff',
                 cursor: 'pointer'
               },
               on: {
                click: () => {
                  this.showDetail(params.row)
                }
              }
              }, params.row.seqNo)
            }
          },
          {
            minWidth: '120',
            label: '电文代码',
            prop: 'cableCode'
          },
          // {
          //   minWidth: '120',
          //   label: '备注',
          //   prop: 'systemName'
          // },
          {
            label: '电文内容',
            minWidth: '300',
            prop: 'content',
            showOverflowTooltip: true
          },
          {
            width: '120',
            label: '状态',
            prop: 'status',
            align: 'center'
          },
          {
            label: '发送时间',
            width: '180',
            align: 'center',
            prop: 'created'
          },
          {
            label: '接收时间',
            width: '180',
            align: 'center',
            prop: 'receiveTime'
          },
          // {
          //   prop: 'linkAddress',
          //   minWidth: '130',
          //   showOverflowTooltip: true,
          //   label: '接收信息'
          // },
          {
            label: '操作',
            fixed: 'right',
            width: 120,
            render: (h, params) => {
              const btnName = this.activeName === 'first' ? '重新发送' : '重新接收'
              return h('div', [
                h('el-button', {
                  props: {
                    type: 'text',
                    size: 'small',
                    loading: false
                  },
                  style: {
                    marginRight: '5px'
                  },
                  on: {
                    click: () => {
                      this.reSend(params.row)
                    }
                  }
                }, btnName)
              ])
            }
          }
        ]
    }
  },
  methods: {
    openQurey() {
      this.dialogVisible = true
      this.dragDialog && this.dragDialog.rest()
    },
    // 获取值集对应lable
    getCodeLabel(key, code) {
      if (!code) {
        return code || ''
      }
      if (this.codesList[key]) {
        return this.codesList[key][code] || ''
      }
    },
    // 计算派发时间
    countAssignTime(h, params) {
      const rs = [h('p', params.row.declareTime)]
      if (!['15', '4', '17', '19'].includes(params.row.eventStatus)) {
        let preword = '已用时'
        let endtime = ''
        if (params.row.completeTime || params.row.completeTime2) {
          endtime = params.row.completeTime || params.row.completeTime2
          preword = '总用时'
        }
        let time = ''
        if (endtime && params.row.declareTime > endtime) {
          time = timeFn(params.row.declareTime, '')
        } else {
        time = timeFn(params.row.declareTime, endtime)
        }
        rs.push(h('p', preword + `${time}`))
      }
      return h('div', {
        style: {
          color: '#e6a700'
        }
       }, rs)
    }
  }
}
